document.write('') document.write('
\n
\n
\n
\n
\n \n\n
\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
<\/td>\n #<\/span>Read-Host -prompt "Enter password to be encrypted in 365securestring.txt " -assecurestring | convertfrom-securestring | out-file C:\\powershell\\365securestring.txt<\/span><\/span><\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n
<\/td>\n $pass<\/span> =<\/span> cat C:\\powershell\\365securestring.txt |<\/span> convertto-securestring<\/span> <\/td>\n <\/tr>\n
<\/td>\n $mycred<\/span> =<\/span> new-object<\/span> -<\/span>typename System.Management.Automation.PSCredential -<\/span>argumentlist "<\/span>john@404john.com"<\/span><\/span>,<\/span>$pass<\/span> <\/td>\n <\/tr>\n
<\/td>\n $O365Session<\/span> =<\/span> New-PSSession<\/span> -<\/span>ConfigurationName Microsoft.Exchange -<\/span>ConnectionUri https://<\/span>ps.outlook.com<\/span>/<\/span>powershell -<\/span>Authentication Basic -<\/span>AllowRedirection -<\/span>Credential $mycred<\/span><\/td>\n <\/tr>\n
<\/td>\n Import-PSSession<\/span> $O365Session<\/span><\/td>\n <\/tr>\n
<\/td>\n Connect-MsolService<\/span> -<\/span>Credential $mycred<\/span><\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n
<\/td>\n '<\/span>'<\/span><\/span> |<\/span> select '<\/span>ReceivedTime'<\/span><\/span>,<\/span>'<\/span>SenderAddress'<\/span><\/span>,<\/span>'<\/span>Subject'<\/span><\/span> |<\/span> Export-Csv<\/span> C:\\powershell\\quar.csv -<\/span>NoTypeInformation<\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n
<\/td>\n $CurrentDate<\/span> =<\/span> Get-Date<\/span><\/td>\n <\/tr>\n
<\/td>\n $OneDayBack<\/span> =<\/span> $CurrentDate.AddDays<\/span><\/span>(-1<\/span>)<\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n
<\/td>\n $Quarantine<\/span> =<\/span> Get-QuarantineMessage<\/span> -<\/span>StartReceivedDate $OneDayBack<\/span> -<\/span>EndReceivedDate $CurrentDate<\/span> |<\/span> select received*<\/span>,<\/span>sender*<\/span>,<\/span>subject <\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n
<\/td>\n $Quarantine<\/span> |<\/span> Export-Csv<\/span> C:\\powershell\\quar.csv -<\/span>Append<\/td>\n <\/tr>\n
<\/td>\n $import<\/span> =<\/span> Import-Csv<\/span> C:\\powershell\\quar.csv |<\/span> ConvertTo-Html<\/span><\/td>\n <\/tr>\n
<\/td>\n $import<\/span> |<\/span> Out-String<\/span><\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n
<\/td>\n Send-MailMessage<\/span> -<\/span>To john@404john.com<\/span><\/span> -<\/span>Subject "<\/span>Daily Quarantine Alert"<\/span><\/span> -<\/span>Body $import<\/span> -<\/span>SmtpServer SMTP01 -<\/span>from Office365@404john.com<\/span><\/span><\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n
<\/td>\n \n<\/td>\n <\/tr>\n<\/table>\n\n\n <\/div>\n\n <\/div>\n<\/div>\n\n <\/div>\n